//
// Created by wsl on 23-4-6.
//

#ifndef DEFECT_DEPTH_CIRCLE_DETECT_H
#define DEFECT_DEPTH_CIRCLE_DETECT_H
#include <iostream>
#include <vector>
#include <cmath>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

cv::Mat tif2png(cv::Mat& gray);
class Circle{
public:
    cv::Point center;
    double radius;
};

//如果斜率为90度会出问题
class Line{
public:
    double k=0;
    double b=0;
    int cal_param(const cv::Point& a,const cv::Point& b);
};
// 计算直线与圆的交点
cv::Point getIntersection(Circle circle, cv::Point p);

std::vector<cv::Point> get_circle(cv::Mat mask);
std::vector<cv::Point> getPointsOnLine(const Circle& c0,cv::Point p);
std::vector<cv::Point> getPolysOnCircle(const Circle& cmax,const Circle& cmin,cv::Point p1,cv::Point p2);

struct cfg3D
{
    int rS[4] = { 610, 610, 710, 730 }; //four readius
    int src_camera=4;   //2D
    int dst_camera=0;
    cv::Point2f src_circle{0,0};
    cv::Point2f dst_circle{0,0};
    cv::Size src_size{0,0};
    cv::Size dst_size{0,0};
};
cv::Mat calMatrix(cfg3D cfg);

cv::Mat calMatrix(cv::Mat&dst_mask,cv::Mat& src_mask,int src_camera=4,int dst_camera=0);

#endif //DEFECT_DEPTH_CIRCLE_DETECT_H
